import { Alova, AlovaWinthoutCache } from '@/utils/http/alova/index';

interface GlobalConfig {
  configGlobal?: boolean;
}

interface NetIfConfig {
  name: string;
  ip: string;
  ipMode: number;
  mode: number;
  nwMask: string;
  hardwareChecksum?: boolean;
  gateway: string;
}

export interface ForbiddenFreq {
  freqMin: number;
  freqMax: number;
}

export interface IpBroadcastWhitelistItem {
  port: number;
  priority: number;
}

export interface IpBroadcastBlacklistItem {
  port: number;
}

export interface IpMulticastWhitelistItem {
  address: string;
  dataRate: number | null;
  maxHopCount: number | null;
  priority: number | null;
}

export interface IpMulticastBlacklistItem {
  address: string;
}

export interface Config extends GlobalConfig {
  dhcpAddressMask: string;
  ipBroadcastFilterMode: number;
  pwAtten2: number;
  ipMulticastWhitelist: IpMulticastWhitelistItem[];
  wifiMacFilterList: any[];
  uartPortB1: number;
  uartPortB0: number;
  uartPortB2: number;
  netIfConfig: NetIfConfig[];
  usbMode: number;
  convergenceGateway: string;
  bluetoothHistoryCount: number;
  presetLongitude: number;
  compoundNodeMasterMac: string;
  disableModules: any[];
  gateway: string;
  enableDualFreq: boolean;
  servicePrioritylist: any[];
  gpo: number;
  span: number;
  ipMulticastIncomingWhitelist: any[];
  pwAtten1: number;
  freqList: number[];
  ipBroadcastBlacklist: IpBroadcastBlacklistItem[];
  infrastructureMode: boolean;
  enableLowDelay: boolean;
  freqDefault: number;
  ip: string;
  enableRssiCtrl: boolean;
  disablePttNotificationSound: boolean;
  transmissionMode: number;
  enableSPISequenceGenerator: boolean;
  ipMulticastIncomingBlacklist: any[];
  presetAltitude: number;
  arpDefendList: any[];
  listenPTTGroupId: any[];
  enableCrossNetworkAudio: boolean;
  forbiddenFreqBands: ForbiddenFreq[];
  debugMode: number;
  disableDSCP: boolean;
  compoundNodeSlaveMacList: any[];
  dataEncryptionKey: string;
  uartDebugPort: number;
  uartMode2: number;
  uartMode0: number;
  uartMode1: number;
  dataEncryptionMode: number;
  name: string;
  convergenceServer: string;
  wifiEnable: boolean;
  bootSystemIndex: number;
  enableBurstAggregation: boolean;
  rfDisable: number;
  antiInterferenceAdvancedMode: number;
  audioHeadGain: number;
  networkRole: number;
  tempThreshold: number;
  nwMask: string;
  linkSnrThreshold: number;
  chargeMode: boolean;
  meshName: string;
  multicastPreferred: boolean;
  dataCompressionMode: number;
  convergenceIp: string;
  minTF: number;
  uartPort2: number;
  compoundNodeWorkMode: number;
  uartPort0: number;
  uartPort1: number;
  stdmaMode: number;
  wifiPassword: string;
  enableSnmpAgent: boolean;
  maxMcformat: number;
  disableNodeId: any[];
  presetLatitude: number;
  dataTransferMode: number;
  uartBaudrate2: number;
  uartBaudrate1: number;
  uartBaudrate0: number;
  dhcpForwardEnable: boolean;
  dnsServer: string;
  wifiChannel: number;
  freqMode: string;
  networkMode: number;
  mcFormats: Record<string, unknown>;
  talkPTTGroupId: number;
  disableLed: boolean;
  videoCodecChnl: number;
  wifiDhcpAddressStart: string;
  dhcpServerGateway: string;
  positionModuleMode: number;
  wifiMacFIlterMode: number;
  dhcpServerEnable: boolean;
  id: number;
  uartIp2: string;
  uartIp0: string;
  uartIp1: string;
  withExternalTimeSignal: boolean;
  uartDebugIP: string;
  compoundNodeMode: number;
  sendToSilenceNodes: boolean;
  ipMulticastBlacklist: IpMulticastBlacklistItem[];
  convergenceIpMask: string;
  adaptiveFreqHopping: boolean;
  queryRouteNodes: any[];
  audioAppMode: number;
  freqListP: any[];
  dscpPrioritylist: any[];
  intraMac0: string;
  intraMac1: string;
  audioMicGain: number;
  ipBroadcastWhitelist: IpBroadcastWhitelistItem[];
  audioMuteLevel: number;
  dhcpServerDns: string;
  ipMulticastFilterMode: number;
  wifiApHide: boolean;
  rangeMode: string;
  enableFEC: boolean;
  audioCodecType: number;
  bluetoothEnable: boolean;
  wifiMode: number;
  nfcMode: number;
  externalAudioAccessorySelection: number;
  enableWebManagement: boolean;
  intraIp1: string;
  intraIp0: string;
  freqListTx: any[];
  ipPrioritylist: any[];
  wakeupNodes: any[];
  enableBeamForming: boolean;
  smartFreqModeSwitchSpeedLevel: number;
  dataCache: number;
  wifiDhcpAddressEnd: string;
  wifiApName: string;
  routes: any[];
  baudrateRs485: number;
  enableHeterogeneousNetwork: boolean;
  enableRangeAdaptive: boolean;
  silence: boolean;
  uartSbus0: boolean;
  uartSbusInterval0: number;
  uartSbus1: boolean;
  uartSbusInterval1: number;
  uartSbus2: boolean;
  uartSbusInterval2: number;
}

//获取config参数
export function getConfig() {
  return Alova.Get<Config>('/config', {
    meta: {
      isReturnNativeResponse: true, // 关键配置, 返回原生响应头
    },
  });
}

export function getConfigWinthoutCache() {
  return AlovaWinthoutCache.Get<Config>('/config', {
    meta: {
      isReturnNativeResponse: true, // 关键配置, 返回原生响应头
    },
  });
}
